//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.baidu.trace;

import android.content.Context;
import android.telephony.CellLocation;
import android.telephony.NeighboringCellInfo;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import com.baidu.trace.a.c;
import java.util.ArrayList;
import java.util.List;

public final class p extends PhoneStateListener {
    private TelephonyManager b;
    private List<Integer> c = new ArrayList();
    private List<Integer> d = new ArrayList();
    private int e = 0;
    public static int a = 0;
    private p.a f = null;
    private int g = 0;
    private int h;
    private String i = "";
    private int j;
    private int k;

    public p(Context var1) {
        this.b = (TelephonyManager)var1.getSystemService("phone");
        this.f = new p.a();
        if(this.b != null) {
            this.b.listen(this.f, 256);
        }

    }

    protected final void a(c var1) {
        if(var1 != null) {
            if(this.b == null) {
                var1.a = false;
            } else {
                if(TextUtils.isEmpty(this.i)) {
                    this.i = this.b.getNetworkOperator();
                }

                p var2;
                if(this.g == 0) {
                    var2 = this;
                    if(this.i != null && this.i.length() >= 3) {
                        try {
                            var2.g = Integer.parseInt(var2.i.substring(0, 3));
                        } catch (Exception var9) {
                            this.g = 0;
                        }
                    } else {
                        this.g = 0;
                    }
                }

                var2 = this;
                CellLocation var3;
                if((var3 = this.b.getCellLocation()) instanceof GsmCellLocation) {
                    GsmCellLocation var4;
                    label104: {
                        var4 = (GsmCellLocation)var3;
                        if(this.i != null && this.i.length() >= 5) {
                            try {
                                var2.h = Integer.parseInt(var2.i.substring(3));
                                break label104;
                            } catch (Exception var10) {
                                ;
                            }
                        }

                        this.h = 0;
                    }

                    this.e = 1;
                    this.j = var4.getLac();
                    this.k = var4.getCid();
                } else if(var3 instanceof CdmaCellLocation) {
                    CdmaCellLocation var14 = (CdmaCellLocation)var3;
                    this.e = 2;
                    this.h = var14.getSystemId();
                    this.j = var14.getNetworkId() >= 0?var14.getNetworkId():0;
                    this.k = var14.getBaseStationId() >= 0?var14.getBaseStationId():0;
                } else {
                    this.e = 0;
                    this.h = 0;
                    this.j = 0;
                    this.k = 0;
                    a = 0;
                }

                var2 = this;
                if(this.d != null) {
                    this.d.clear();
                } else {
                    this.d = new ArrayList();
                }

                if(this.c != null) {
                    this.c.clear();
                } else {
                    this.c = new ArrayList();
                }

                List var12 = this.b.getNeighboringCellInfo();
                if(var12 != null && !var12.isEmpty()) {
                    int var15 = var12.size();
                    int var5 = 0;

                    for(int var6 = 0; var6 < var15 && var5 < 6; ++var6) {
                        int var7 = ((NeighboringCellInfo)var12.get(var6)).getLac();
                        int var8;
                        if((var8 = ((NeighboringCellInfo)var12.get(var6)).getCid()) > 0 && var7 > 0) {
                            var2.c.add(Integer.valueOf(var7));
                            var2.d.add(Integer.valueOf(var8));
                            ++var5;
                        }
                    }
                }

                var1.b = Integer.valueOf(this.e).byteValue();
                var1.c = Integer.valueOf(a).byteValue();
                var1.d = Integer.valueOf(this.g).shortValue();
                var1.e = Integer.valueOf(this.h).shortValue();
                var1.f = this.j;
                var1.g = this.k;
                if(this.c != null && this.d != null) {
                    int var11 = this.c.size() <= this.d.size()?this.c.size():this.d.size();
                    var1.h = new int[var11];
                    var1.i = new int[var11];

                    for(int var13 = 0; var13 < var11; ++var13) {
                        var1.h[var13] = ((Integer)this.c.get(var13)).intValue();
                        var1.i[var13] = ((Integer)this.d.get(var13)).intValue();
                    }

                    var1.a = true;
                }
            }
        }
    }

    protected final boolean a() {
        return this.b != null;
    }

    protected final void b() {
        if(this.c != null) {
            this.c.clear();
            this.c = null;
        }

        if(this.d != null) {
            this.d.clear();
            this.d = null;
        }

    }

    public class a extends PhoneStateListener {
        public a() {
        }

        public final void onSignalStrengthsChanged(SignalStrength var1) {
            super.onSignalStrengthsChanged(var1);
            if(var1.isGsm()) {
                if(99 != var1.getGsmSignalStrength()) {
                    p.a = (var1.getGsmSignalStrength() << 1) - 113;
                } else {
                    p.a = 0;
                }
            } else {
                p.a = var1.getCdmaDbm();
            }
        }
    }
}
